#include "sRegister.h"

#include <sstream>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeIterator.h>
#include "misc/Interface.h"
#include "misc/Debug.h"
#include "server/net/sRegister.h"
#include "server/net/NetworkControl.h"
/*********************************************************/
void sRegister::execute()
{
	// The server only sends register messages so we do nothing here
}
/*********************************************************/
std::string sRegister::serialize() const
{
	NetworkControl& ns = NetworkControl::Instance();
	std::ostringstream		ostr;
	id = ns.getID();

	ostr << "<GS id='" << id << "'>";
	ostr << "<Register>";
	ostr << "<hostaddr>" << hostAddr << "</hostaddr>";
	ostr << "<ringname>" << ringName << "</ringname>";
	ostr << "<ringaddr>" << ringAddr << "</ringaddr>";
	ostr << "</Register>";
	ostr << "</GS>";

	return( ostr.str() );
}
/*********************************************************/
void sRegister::deserialize(Poco::XML::NodeIterator& it)
{
	// This message is only sent by the server, not received
}
/*********************************************************/
void sRegister::setRingName(const std::string& name)
{
	ringName = name;
}
/*********************************************************/
void sRegister::setRingAddr(const std::string& addr)
{
	ringAddr = addr;
}
/*********************************************************/
void sRegister::setHostAddr(const std::string& addr)
{
	hostAddr = addr;
}
/*********************************************************/
std::string sRegister::getRingName() const
{
	return ringName;
}
/*********************************************************/
std::string sRegister::getHostAddr() const
{
	return hostAddr;
}
/*********************************************************/
std::string sRegister::getRingAddr() const
{
	return ringAddr;
}
/*********************************************************/
